limsExportTemplate.editPage = {

    getGridParam: function () {
        var _this = this;
        return {
            type: 'grid',
            id: 'lims-export-template-edit-list-grid',
            url: limsExportTemplate.baseUrl + '/queries/raw',
            service: 'limsExportTemplateServiceImpl',
            dbTable: 'T_LIMS_EXPORT_TEMPLATE',
            columns: limsExportTemplate.getEditListColumns(),
            onCellClick: function (field, row) {
                field === 'fileName' && Gikam.openFile(row.templateFileId, false);
            },
            onLoadSuccess: function (data) {
                if (!Gikam.isEmpty(data)) {
                    this.activeRowByIndex(0);
                } else {
                    Gikam.cleanCompData(['lims-export-template-edit-list-base-info-form']);
                }
            },
            deleteFormatter: function (row) {
                return row.templateCode || row.templateName;
            },
            onRowActive: function (index, row) {

                Gikam.getAsyncComp('lims-export-template-edit-list-base-info-form').done(function (form) {
                    form.refresh({
                        url: Gikam.printf(limsExportTemplate.baseUrl + '/{id}', {
                            id: row.id
                        })
                    });
                });

            },
            toolbar: [{
                type: 'button',
                text: 'GIKAM.BUTTON.INSERT',
                icon: 'add',
                onClick: function () {
                    Gikam.preInsert({
                        modalTitle: 'GIKAM.BUTTON.INSERT',
                        fields: limsExportTemplate.getBaseInfoFormFields(),
                        url: limsExportTemplate.baseUrl
                    }).done(function (id) {
                        Gikam.getComp('lims-export-template-edit-list-grid').refresh();
                    });
                }
            }, {
                type: 'button',
                text: 'GIKAM.BUTTON.DELETE',
                icon: 'remove-row',
                onClick: function () {
                    Gikam.getComp('lims-export-template-edit-list-grid').deleteRows(limsExportTemplate.baseUrl);
                }
            }]
        }
    },

    create: function () {
        var _this = this;
        Gikam.create('layout', {
            id: 'lims-export-template-edit-list-layout',
            renderTo: workspace.window.$dom,
            center: {
                items: [this.getGridParam()]
            }
        });
    },

    init: function () {
        this.create();
    }
};
